export default {
  getLocation(){
    return new Promise(function (resolve, reject) {
      const geolocation = new BMap.Geolocation();
      geolocation.getCurrentPosition((position)=>{
        let result = {}
        result.city = position.address.city;             //获取城市信息
        result.province = position.address.province;     //获取省份信息
        result.point = position.point
        resolve(result)
      })
    })
  },
  getDistance:function(pt1,pt2){
    var map = new BMap.Map("BMap");
    var point1 = new BMap.Point(pt1.lng,pt1.lat);
    var point2 = new BMap.Point(pt2.lng,pt2.lat);
    var distance = map.getDistance(point1,point2);
    distance = Math.round(distance/1000) //公里
    return distance;
  },
}
